<?php
namespace app\api\model\goods;
use think\facade\Db;
class RefundOrder{
	
	public function findRefundRemark($_where,$_field)
	{
		return Db::name("shop_refund_remark")->where($_where)->field($_field)->find();
	}
	
	public function selectRefundRemark($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("shop_refund_remark")->where($_where)->field($_field)->limit(current($_limit),end($_limit))->order($_order)->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function insertRefund($_data)
	{
		return Db::name("shop_order_refund")->insert($_data);
	}
	
	public function findRefund($_where,$_field)
	{
		return Db::name("shop_order_refund")->where($_where)->field($_field)->find();
	}
	
	public function updateRefund($_up,$_where)
	{
		return Db::name("shop_order_refund")->where($_where)->update($_up);
	}
	
	public function insertRefundDetails($_data)
	{
		return Db::name("shop_order_refund_details")->insert($_data);
	}
	
	/**
	 * @title 查询退款订单列表
	 */
	public function findRefundOrder($_where,$_field){
		return Db::name("shop_order_refund")->alias("r")
			->join("shop_order o","r.order_id=o.id")
			->where($_where)
			->field($_field)
			->find();
	}
	
	public function selectRefundOrder($_where,$_field,$_limit,$_order)
	{
		$_data=Db::name("shop_order_refund")->alias("r")
			->join("shop_order o","r.order_id=o.id")
			->where($_where)
			->field($_field)
			->limit(current($_limit),end($_limit))
			->order($_order)
			->select();
		return empty($_data)?:$_data->toArray();	
	}
	
	public function selectRefundOrderDetails($_where,$_field)
	{
		$_data=Db::name("shop_order_refund_details")
			->alias("rd")
			->join("shop_order_details od","od.id=rd.details_id")
			->join("shop_goods g","g.id=od.goods_id")
			->where($_where)
			->field($_field)
			->select();
		return empty($_data)?:$_data->toArray();
	}
	
}
?>